package com.wicket.okrapp.base.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.wicket.okrapp.base.service.MOmsBasicInstanceAssistBehaviorCurrentStepService;
import com.wicket.okrapp.base.service.dto.req.QueryCurrentStepTestDataListReq;
import com.wicket.okrapp.common.util.CommonFunctionHelper;
import com.wicket.okrapp.dal.mapper.mbg.OmsBasicInstanceAssistBehaviorCurrentStepMapper;
import com.wicket.okrapp.dal.po.mbg.OmsBasicInstanceAssistBehaviorCurrentStep;
import org.apache.skywalking.apm.toolkit.trace.Tag;
import org.apache.skywalking.apm.toolkit.trace.Tags;
import org.apache.skywalking.apm.toolkit.trace.Trace;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.wicket.okrapp.base.service.dto.req.QueryBizAppServiceContCurrentBstepDetailReq;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import java.util.ArrayList;
import java.util.List;
import com.wicket.okrapp.common.exception.BizException;
import com.wicket.okrapp.base.service.dto.req.QueryBizAppServiceContCurrentBstepListReq;
import com.wicket.okrapp.common.dto.FieldInfo;
import java.util.stream.Collectors;
import com.wicket.okrapp.base.service.dto.req.BatchQueryContCurrentBstepReq;

/**
 * @author ：
 * @since 2022/1/19 15:39
 *
 *
 * @version 1.0
 */
@Service
public class MOmsBasicInstanceAssistBehaviorCurrentStepServiceImpl
        extends ServiceImpl<OmsBasicInstanceAssistBehaviorCurrentStepMapper, OmsBasicInstanceAssistBehaviorCurrentStep>
        implements MOmsBasicInstanceAssistBehaviorCurrentStepService {

    @Autowired
    OmsBasicInstanceAssistBehaviorCurrentStepMapper omsBasicInstanceAssistBehaviorCurrentStepMapper;

    /**
   * 3-11-04新增业务应用内容当前行为步骤[2427]
   * gen by moon at 10/15/2022, 10:04:54 PM
   */
 @Trace(operationName = "3-11-04新增业务应用内容当前行为步骤")
 @Tags({@Tag(key = "参数",value = "arg[0]"),
 @Tag(key = "返回值",value = "returnedObj")})
  @Override
  @Transactional(rollbackFor=Exception.class)
  public  String  addBizAppServiceContCurrentBstep(OmsBasicInstanceAssistBehaviorCurrentStep omsBasicInstanceAssistBehaviorCurrentStep) {
     omsBasicInstanceAssistBehaviorCurrentStep.setBehaviorCurrentStepId(CommonFunctionHelper.getUid());//DISTRIBUTED_ID
omsBasicInstanceAssistBehaviorCurrentStep.setInductionRecordId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecInductionRecordId());//CURRENT_INDUCTIONID
omsBasicInstanceAssistBehaviorCurrentStep.setOperationInductionId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecInductionRecordId());//CURRENT_INDUCTIONID
omsBasicInstanceAssistBehaviorCurrentStep.setCreateInductionId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecInductionRecordId());//CURRENT_INDUCTIONID
omsBasicInstanceAssistBehaviorCurrentStep.setCreateTime(CommonFunctionHelper.getCurrentTime());//SYSTEM_CURRENT_TIME
omsBasicInstanceAssistBehaviorCurrentStep.setOperateTime(CommonFunctionHelper.getCurrentTime());//SYSTEM_CURRENT_TIME
omsBasicInstanceAssistBehaviorCurrentStep.setIsValid("FALSE");
omsBasicInstanceAssistBehaviorCurrentStep.setSpaceId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecSpaceId());//CURRENT_SPACEID
omsBasicInstanceAssistBehaviorCurrentStep.setAppId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecAppId());//CURRENT_APPID
     if(super.save(omsBasicInstanceAssistBehaviorCurrentStep)){
        return omsBasicInstanceAssistBehaviorCurrentStep.getBehaviorCurrentStepId();
     }else {
        return "-1";
     }
    
  }
/**
   * 3-13-06查业务应用服务内容当前行为步骤[2952]
   * gen by moon at 3/30/2023, 12:39:17 PM
   */
 @Trace(operationName = "3-13-06查业务应用服务内容当前行为步骤")
 @Tags({@Tag(key = "参数",value = "arg[0]"),
 @Tag(key = "返回值",value = "returnedObj")})
  @Override
  @Transactional(rollbackFor=Exception.class)
  public  OmsBasicInstanceAssistBehaviorCurrentStep  queryBizAppServiceContCurrentBstepDetail(QueryBizAppServiceContCurrentBstepDetailReq reqDto) {
     
        try {
         reqDto.setIsValid("FALSE");
reqDto.setSpaceId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecSpaceId());//CURRENT_SPACEID
            QueryWrapper<OmsBasicInstanceAssistBehaviorCurrentStep> queryWrapper = new QueryWrapper<>();
            Map<String, Object> fieldInfoMap = null;
            fieldInfoMap = CommonFunctionHelper.objectToMapForLamBda(reqDto);
            CommonFunctionHelper.buildQueryWrapperEq(queryWrapper, fieldInfoMap, new ArrayList<>());
            queryWrapper.orderByDesc("create_time");
            List<OmsBasicInstanceAssistBehaviorCurrentStep> retList = super.list(queryWrapper);
            if(retList!=null && retList.size()>0){
                OmsBasicInstanceAssistBehaviorCurrentStep retData = retList.get(0);
                
                return retData;
            }
            return null;
      } catch (Exception e) {
          e.printStackTrace();
          throw new BizException("-1",e,false);
      }
  }
/**
   * 3-13-06查业务应用服务内容当前行为步骤列表[2956]
   * gen by moon at 10/15/2022, 10:04:56 PM
   */
 @Trace(operationName = "3-13-06查业务应用服务内容当前行为步骤列表")
 @Tags({@Tag(key = "参数",value = "arg[0]"),
 @Tag(key = "返回值",value = "returnedObj")})
  @Override
  @Transactional(rollbackFor=Exception.class)
  public  List<OmsBasicInstanceAssistBehaviorCurrentStep>  queryBizAppServiceContCurrentBstepList(QueryBizAppServiceContCurrentBstepListReq reqDto) {
     
        try {
            QueryWrapper<OmsBasicInstanceAssistBehaviorCurrentStep> queryWrapper = new QueryWrapper<>();
            
            
            Map<String, Object> fieldInfoMap = null;
            fieldInfoMap = CommonFunctionHelper.objectToMapForLamBda(reqDto);
            List<FieldInfo> compareList = CommonFunctionHelper.getRangeField(OmsBasicInstanceAssistBehaviorCurrentStep.class);
            CommonFunctionHelper.buildQueryWrapperCompare(queryWrapper, compareList, fieldInfoMap);
            List<FieldInfo> likeList = CommonFunctionHelper.getLikeFiled(OmsBasicInstanceAssistBehaviorCurrentStep.class);
            CommonFunctionHelper.buildQueryWrapperLike(queryWrapper,likeList,fieldInfoMap);
            likeList.addAll(compareList);
            CommonFunctionHelper.buildQueryWrapperEq(queryWrapper, fieldInfoMap,likeList);
            List<FieldInfo> orderList = CommonFunctionHelper.getOrderList(OmsBasicInstanceAssistBehaviorCurrentStep.class);
            //CommonFunctionHelper.buildQueryWrapperOrder(queryWrapper, orderList);
            
            return ((List<OmsBasicInstanceAssistBehaviorCurrentStep>) super.list(queryWrapper));
        } catch (Exception e) {
            e.printStackTrace();
            throw new BizException("-1",e,false);
        }
  }
/**
   * 3-13-06批量增业务应用服务内容当前行为步骤[2961]
   * gen by moon at 10/15/2022, 10:04:56 PM
   */
 @Trace(operationName = "3-13-06批量增业务应用服务内容当前行为步骤")
 @Tags({@Tag(key = "参数",value = "arg[0]"),
 @Tag(key = "返回值",value = "returnedObj")})
  @Override
  @Transactional(rollbackFor=Exception.class)
  public  boolean  batchAddBizAppServiceContCurrentBstep(List<OmsBasicInstanceAssistBehaviorCurrentStep> omsBasicInstanceAssistBehaviorCurrentStep) {
     
      if(omsBasicInstanceAssistBehaviorCurrentStep==null || omsBasicInstanceAssistBehaviorCurrentStep.size()==0){
        return false;
      }
      
      return super.saveBatch(omsBasicInstanceAssistBehaviorCurrentStep.stream().map(item->{
       item.setBehaviorCurrentStepId(CommonFunctionHelper.getUid());//DISTRIBUTED_ID
item.setInductionRecordId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecInductionRecordId());//CURRENT_INDUCTIONID
item.setOperationInductionId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecInductionRecordId());//CURRENT_INDUCTIONID
item.setOperateTime(CommonFunctionHelper.getCurrentTime());//SYSTEM_CURRENT_TIME
item.setIsValid("FALSE");
item.setSpaceId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecSpaceId());//CURRENT_SPACEID
item.setAppId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecAppId());//CURRENT_APPID
          return item;
      }).collect(Collectors.toList()));
  }
/**
   * 3-13-06修改业务应用服务内容当前行为步骤[2963]
   * gen by moon at 10/15/2022, 10:04:57 PM
   */
 @Trace(operationName = "3-13-06修改业务应用服务内容当前行为步骤")
 @Tags({@Tag(key = "参数",value = "arg[0]"),
 @Tag(key = "返回值",value = "returnedObj")})
  @Override
  @Transactional(rollbackFor=Exception.class)
  public  boolean  updateBizAppServiceContCurrentBstep(OmsBasicInstanceAssistBehaviorCurrentStep omsBasicInstanceAssistBehaviorCurrentStep) {
     
        return super.updateById(omsBasicInstanceAssistBehaviorCurrentStep);
  }
/**
   * 3-13-06批量查询内容当前行为步骤[3970]
   * gen by moon at 10/15/2022, 10:04:58 PM
   */
 @Trace(operationName = "3-13-06批量查询内容当前行为步骤")
 @Tags({@Tag(key = "参数",value = "arg[0]"),
 @Tag(key = "返回值",value = "returnedObj")})
  @Override
  @Transactional(rollbackFor=Exception.class)
  public  List<OmsBasicInstanceAssistBehaviorCurrentStep>  batchQueryContCurrentBstep(BatchQueryContCurrentBstepReq reqDto) {
     
        try {
            QueryWrapper<OmsBasicInstanceAssistBehaviorCurrentStep> queryWrapper = new QueryWrapper<>();
            reqDto.setSpaceId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecSpaceId());//CURRENT_SPACEID
reqDto.setAppId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecAppId());//CURRENT_APPID
            if(reqDto.getBizAppServiceContCurrentBstepList()==null || reqDto.getBizAppServiceContCurrentBstepList().isEmpty()){
                    return new ArrayList<>();
                }
        queryWrapper.in("entity_id", reqDto.getBizAppServiceContCurrentBstepList());
            Map<String, Object> fieldInfoMap = null;
            fieldInfoMap = CommonFunctionHelper.objectToMapForLamBda(reqDto);
            List<FieldInfo> compareList = CommonFunctionHelper.getRangeField(OmsBasicInstanceAssistBehaviorCurrentStep.class);
            CommonFunctionHelper.buildQueryWrapperCompare(queryWrapper, compareList, fieldInfoMap);
            List<FieldInfo> likeList = CommonFunctionHelper.getLikeFiled(OmsBasicInstanceAssistBehaviorCurrentStep.class);
            CommonFunctionHelper.buildQueryWrapperLike(queryWrapper,likeList,fieldInfoMap);
            likeList.addAll(compareList);
            CommonFunctionHelper.buildQueryWrapperEq(queryWrapper, fieldInfoMap,likeList);
            List<FieldInfo> orderList = CommonFunctionHelper.getOrderList(OmsBasicInstanceAssistBehaviorCurrentStep.class);
            //CommonFunctionHelper.buildQueryWrapperOrder(queryWrapper, orderList);
            
            return ((List<OmsBasicInstanceAssistBehaviorCurrentStep>) super.list(queryWrapper));
        } catch (Exception e) {
            e.printStackTrace();
            throw new BizException("-1",e,false);
        }
  }
/**
   * 3-13-06删除业务服务内容当前步骤[4230]
   * gen by moon at 11/2/2022, 7:41:48 AM
   */
 @Trace(operationName = "3-13-06删除业务服务内容当前步骤")
 @Tags({@Tag(key = "参数",value = "arg[0]"),
 @Tag(key = "返回值",value = "returnedObj")})
  @Override
  @Transactional(rollbackFor=Exception.class)
  public  boolean  deleteBizAppServiceContCurrentBstep(String behaviorCurrentStepId ) {
     
      return super.removeById(behaviorCurrentStepId);
  }
/**
   * M1查询当前步骤测试列表[5117]
   * gen by moon at 11/4/2022, 7:21:27 AM
   */
 @Trace(operationName = "M1查询当前步骤测试列表")
 @Tags({@Tag(key = "参数",value = "arg[0]"),
 @Tag(key = "返回值",value = "returnedObj")})
  @Override
  @Transactional(rollbackFor=Exception.class)
  public  List<OmsBasicInstanceAssistBehaviorCurrentStep>  queryCurrentStepTestDataList(QueryCurrentStepTestDataListReq reqDto) {

        try {
            QueryWrapper<OmsBasicInstanceAssistBehaviorCurrentStep> queryWrapper = new QueryWrapper<>();


            Map<String, Object> fieldInfoMap = null;
            fieldInfoMap = CommonFunctionHelper.objectToMapForLamBda(reqDto);
            List<FieldInfo> compareList = CommonFunctionHelper.getRangeField(OmsBasicInstanceAssistBehaviorCurrentStep.class);
            CommonFunctionHelper.buildQueryWrapperCompare(queryWrapper, compareList, fieldInfoMap);
            List<FieldInfo> likeList = CommonFunctionHelper.getLikeFiled(OmsBasicInstanceAssistBehaviorCurrentStep.class);
            CommonFunctionHelper.buildQueryWrapperLike(queryWrapper,likeList,fieldInfoMap);
            likeList.addAll(compareList);
            CommonFunctionHelper.buildQueryWrapperEq(queryWrapper, fieldInfoMap,likeList);
            List<FieldInfo> orderList = CommonFunctionHelper.getOrderList(OmsBasicInstanceAssistBehaviorCurrentStep.class);
            //CommonFunctionHelper.buildQueryWrapperOrder(queryWrapper, orderList);

            return ((List<OmsBasicInstanceAssistBehaviorCurrentStep>) super.list(queryWrapper));
        } catch (Exception e) {
            e.printStackTrace();
            throw new BizException("-1",e,false);
        }
  }
/**
   * M3批量删当前步骤测试[5118]
   * gen by moon at 11/4/2022, 7:21:27 AM
   */
 @Trace(operationName = "M3批量删当前步骤测试")
 @Tags({@Tag(key = "参数",value = "arg[0]"),
 @Tag(key = "返回值",value = "returnedObj")})
  @Override
  @Transactional(rollbackFor=Exception.class)
  public  boolean  batchDeleteCurrentStepTestData(List<String> reqDto) {

          if(reqDto==null || reqDto.size()==0){
            return false;
          }

          return super.removeByIds(reqDto);
  }
}
